package com.situ.firmadmin.controller;



import com.situ.firmadmin.pojo.LoginLog;
import com.situ.firmadmin.pojo.query.LoginLogQuery;
import com.situ.firmadmin.service.ILoginLogService;
import com.situ.firmadmin.util.PageResult;
import com.situ.firmadmin.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/loginlog")
public class LoginLogController {
    @Autowired
    private ILoginLogService loginLogService;

    @GetMapping("/selectByPage")
    public Result list(LoginLogQuery loginLogQuery){
        PageResult pageResult = loginLogService.list(loginLogQuery);
        Map<String, Object> map = new HashMap<>();
        map.put("total",pageResult.getCount());
        map.put("list",pageResult.getData());
        return Result.ok(map);
    }

    @GetMapping("/selectById/{id}")
    public Result selectById(@PathVariable Integer id){
        LoginLog loginLog=loginLogService.selectById(id);
        return Result.ok(loginLog);
    }

    @DeleteMapping("/deleteSelected/{ids}")
    public Result deleteSelected(@PathVariable Integer[] ids){
        loginLogService.deleteSelected(ids);
        return Result.ok("删除成功！");
    }

    @DeleteMapping("/deleteById/{id}")
    public Result deleteById(@PathVariable Integer id){
        loginLogService.deleteById(id);
        return Result.ok("删除成功！");
    }

    @DeleteMapping("/deleteAll")
    public Result deleteAll(){
        loginLogService.deleteAll();
        return Result.ok("清除成功！");
    }
}
